﻿Public Class RahorroPrevio

    Public Shared Function SeleccionarAhorroPrevio(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EahorroPrevio)
        Dim ahorroPrevios As List(Of EahorroPrevio) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                ahorroPrevios = DahorroPrevio.SeleccionarAhorroPrevio(descEmpresa, False, pSeparacionVenta)
                If ahorroPrevios Is Nothing Then ahorroPrevios = New List(Of EahorroPrevio)
                If DisplaySelect Then ahorroPrevios.Insert(0, New EahorroPrevio("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return ahorroPrevios
    End Function
    Public Shared Function SeleccionarAhorroPrevio_SelXSeparacionVenta(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EahorroPrevio)
        Dim ahorroPrevios As List(Of EahorroPrevio) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                ahorroPrevios = DahorroPrevio.SeleccionarAhorroPrevio_SelXSeparacionVenta(descEmpresa, False, pSeparacionVenta)
                If ahorroPrevios Is Nothing Then ahorroPrevios = New List(Of EahorroPrevio)
                If DisplaySelect Then ahorroPrevios.Insert(0, New EahorroPrevio("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return ahorroPrevios
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pAhorroPrevio As EahorroPrevio) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DahorroPrevio.Añadir(descEmpresa, pAhorroPrevio)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pAhorroPrevio As EahorroPrevio) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DahorroPrevio.Editar(descEmpresa, pAhorroPrevio)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByRef idSeparacionVenta As Integer, ByVal pAhorroPrevio As EahorroPrevio) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DahorroPrevio.Eliminar(descEmpresa, idSeparacionVenta, pAhorroPrevio)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function SeleccionarAhorroPrevioTemporal(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pSeparacionVenta As EseparacionVenta) As List(Of EahorroPrevio)
        Dim ahorroPrevios As List(Of EahorroPrevio) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                ahorroPrevios = DahorroPrevio.SeleccionarAhorroPrevioTemporal(descEmpresa, False, pSeparacionVenta)
                If ahorroPrevios Is Nothing Then ahorroPrevios = New List(Of EahorroPrevio)
                If DisplaySelect Then ahorroPrevios.Insert(0, New EahorroPrevio("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return ahorroPrevios
    End Function
    Public Shared Function AñadirTemporal(ByVal descEmpresa As String, ByVal pAhorroPrevio As EahorroPrevio) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DahorroPrevio.AñadirTemporal(descEmpresa, pAhorroPrevio)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EditarTemporal(ByVal descEmpresa As String, ByVal pAhorroPrevio As EahorroPrevio) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DahorroPrevio.EditarTemporal(descEmpresa, pAhorroPrevio)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EliminarTemporal(ByVal descEmpresa As String, ByRef idSeparacionVenta As Integer, ByVal pAhorroPrevio As EahorroPrevio) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DahorroPrevio.EliminarTemporal(descEmpresa, idSeparacionVenta, pAhorroPrevio)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

End Class
